package com.aaa.controller;

import com.aaa.dao.ActivityDao;
import com.aaa.dao.ActivityMapper;
import com.aaa.dao.FcartMapper;
import com.aaa.entity.Fcart;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wsc.entity.Activity;
import com.wsc.entity.Inventory;
import com.wsc.entity.ResultMsg;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@RequestMapping("activity")
@RestController
public class ActivityController {
    @Resource
    ActivityDao activityDao;
    @Resource
    ActivityMapper activityMapper;
    @Resource
    FcartMapper fcartMapper;
    @RequestMapping("select")
    public Object select(){
        return activityDao.select1();
    }
    @RequestMapping("select2")
    public Integer select2(Integer aid){
        System.out.println(activityDao.select2(aid
        ));
        return activityDao.select2(aid);
    }
    @RequestMapping("buy")
    public Integer buy(Fcart fcart,Integer aid){
//        Fcart fcart=new Fcart();
//        fcart.setBook(activity.getBid());
//        fcart.setNumber(1);
//        fcart.setPrice(activity.getPrice());
//        fcart.setFuser(f_user);
        Date date=new Date();
        SimpleDateFormat sdft=new SimpleDateFormat("yyyy-MM-dd");
        String time=sdft.format(date);
        fcart.setTime(time);
//        Integer nums= fcart.getNumber();
//        Activity activity=new Activity();
//        activity.setNums(nums);
//        activity.setAid(aid);
//        activityDao.update1(activity);
        fcart.setActivity(aid);

        return fcartMapper.insert(fcart);
    }
}
